<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>档案管理系统</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

    <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/dist/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/dist/css/ionicons.min.css">
    <link rel="stylesheet" href="/static/dist/css/AdminLTE.min.css">
    <link rel="stylesheet" href="/static/dist/css/skins/all-skins.min.css">
    <link rel="stylesheet" href="/static/css/bootstrap-treeview.css">
    <link rel="stylesheet" href="/static/css/bootstrapValidator.min.css">
    <link rel="stylesheet" href="/static/plugins/datepicker/datepicker3.css">
    <link rel="stylesheet" href="/static/layer/theme/default/layer.css">
    <link rel="stylesheet" href="/static/css/fileinput.min.css">
    <link rel="stylesheet" href="/static/webCss/dayj.css?v=shujubuwqd12138">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="/static/plugins/ie9/html5shiv.min.js"></script>
    <script src="/static/plugins/ie9/respond.min.js"></script>
    <![endif]-->
</head>
<body class="hold-transition skin-blue" style="font-size: medium">
<div class="content row" id="gmlpz">
    <div class="col-xs-12 text-center" style="margin-top: -17px;padding-bottom: 20px;">
        <div class="btn-group" style="padding-top: 24px">
            <button @click.prevent="clickflfg" class="btn btn-primary btn1" id="fafgBtn">法律法规名称</button>
            <button @click.prevent="clickhybz" class="btn btn-default btn2" id="hybzBtn">行业标准</button>
        </div>
    </div>
    <div class="row col-xs-12" style="padding-right: 0px">
        <div class="col-xs-offset-9 col-xs-3" style="display: table;padding-right: 0px;padding-bottom: 1%">
            <input v-model="keyword" type="text" class="form-control" placeholder="输入关键字进行模糊查询">
            <span @click="search" class="input-group-addon btn  btn-default"><i class="fa fa-search"></i></span>
        </div>
    </div>
    <div class=" col-xs-12" v-show="flfg">
        <table class="table table-bordered table-hover text-center" id="flfgTable">

        </table>
    </div>
    <div class=" col-xs-12" v-show="hybz">
        <table class="table table-bordered table-hover text-center" id="hybzTable">

        </table>
    </div>
</div>
<script src="/static/plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
<!-- Slimscroll -->
<script src="/static/plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="/static/plugins/fastclick/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="/static/dist/js/app.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="/static/dist/js/demo.js"></script>
<!--tabs-->
<script src="/static/dist/js/app_iframe.js"></script>
<script src="/static/js/bootstrap-treeview.js"></script>
<script src="/static/js/bootstrapValidator.min.js"></script>
<script src="/static/plugins/datepicker/bootstrap-datepicker.js"></script>
<script src="/static/plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
<script src="/static/js/vue.js"></script>
<script src="/static/js/vue-resource.min.js"></script>
<script src="/static/layer/layer.js"></script>
<script src="/static/js/myJs.js?v=shujubuwqd12138"></script>
<script src="/static/js/fileinput.min.js"></script>
<script src="/static/js/zh.js"></script>
<script src="/static/js/bootstrap-table.min.js"></script>
<script src="/static/js/bootstrap-table-zh-CN.js"></script>
<script src="/static/js/newJs.js?v=shujubuwqd12138"></script>

<script type="text/javascript">
    newCss("/static/webCss/dayj.css");
    function paramsMatter(value,row,index) {
        var span=document.createElement('span');
        span.setAttribute('title',value);
        span.innerHTML = value;
        return span.outerHTML;
    }

    function downLoad(id){
        window.location.href='/fglr/api/downloadFg?id='+id;
    }
    function downLoad2(id){
        window.location.href='/hxbz/api/downloadFg?id='+id;
    }

    function showPdf(id) {
        var u = '/fglr/api/previewFg/'+id;
        top.addTabs({
            id: "63233",
            text: "PDF浏览器",
            icon: "fa fa-circle-o",
            url: "/static/pdf/web/viewer.html?file="+u,
            targetType: "iframe-tab",
            close:true
        });
    }
    function showPdf2(id) {
        var u = '/hxbz/api/previewFg/'+id;
        top.addTabs({
            id: "63233",
            text: "PDF浏览器",
            icon: "fa fa-circle-o",
            url: "/static/pdf/web/viewer.html?file="+u,
            targetType: "iframe-tab",
            close:true
        });
    }
    var vue = new Vue({
        el:"#gmlpz",
        data:{
            keyword:null,
            path:null,
            flfg:true,
            hybz:false,
        },
        methods:{
            search:function(){
                if(this.flfg){
                    this.searchFlfg();
                }else {
                    this.searchHybz();
                }
            },
            //根据关键字查询法律法规
            searchFlfg:function(){
                if(this.keyword == 'null'){
                    var url = '/fglr/api/querykeyword';
                }else {
                    var url = '/fglr/api/querykeyword?keyword='+this.keyword;
                }
                $("#flfgTable").bootstrapTable('destroy');
                $('#flfgTable').bootstrapTable({
                    url: url,
                    contentType: "application/json; charset=UTF-8",
                    type: "GET",
                    dataType: 'json',
                    queryParamsType: "",
                    sortName : 'rgsj',
                    sortOrder : 'desc',
                    singleSelect: true,
                    paginationShowPageGo: true,
                    pageNumber:1,
                    pageSize:5,
                    queryParams: function (params) {
                        return {'pageNum':params.pageNumber,'pageSize':params.pageSize,'sort':params.sortOrder};
                    },
                    striped: true,
                    smartDisplay:false,
                    cache: false,
                    //pagination: true,
                    pageList: [5,10],
                    sidePagination: 'server',
                    toolbar: "#addtool",
                    columns: [{
                        field: 'name',
                        title: '标准名称',
                        formatter:paramsMatter
                    }, {
                        field: 'pzsj',
                        title: '批准时间',
                        formatter:paramsMatter
                    }, {
                        field: 'uploadtime',
                        title: '生效时间',
                        formatter:paramsMatter
                    }, {
                        field: 'pzdw',
                        title: '批准单位',
                        formatter:paramsMatter
                    },{
                        title: '操作',
                        formatter: function (value, row, index) {
                            var aStr = '<a class="czBtn" href="javascript:showPdf(\''+row.id+'\')">查看</a>';
                            aStr += '<a class="czBtn" href="javascript:downLoad(\''+row.id+'\')">下载</a>';
                            return aStr;
                        },
                    }],
                    responseHandler: function (res) {  //后台返回的结果
                        if (res.code == "200") {
                            var data = res.data;
                            var NewData = [];
                            for(i=0;i<data.length;i++){
                                var dd = data[i];
                                dd.roleName = roleId2RoleName(dd.roleId);
                                NewData.push(dd);
                            }
                            var data = {
                                total: res.data.total,
                                rows: NewData
                            };
                            return data;
                        }
                    }
                });
            },
            //根据关键字查询行业标准
            searchHybz:function(){
                if(this.keyword == 'null'){
                    var url = '/hxbz/api/querykeyword';
                }else {
                    var url = '/hxbz/api/querykeyword?keyword='+this.keyword;
                }
                $("#hybzTable").bootstrapTable('destroy');
                $('#hybzTable').bootstrapTable({
                    url: url,
                    contentType: "application/json; charset=UTF-8",
                    type: "GET",
                    dataType: 'json',
                    queryParamsType: "",
                    sortName : 'rgsj',
                    sortOrder : 'desc',
                    singleSelect: true,
                    paginationShowPageGo: true,
                    pageNumber:1,
                    pageSize:5,
                    queryParams: function (params) {
                        return {'pageNum':params.pageNumber,'pageSize':params.pageSize,'sort':params.sortOrder};
                    },
                    striped: true,
                    smartDisplay:false,
                    cache: false,
                    //pagination: true,
                    pageList: [5,10],
                    sidePagination: 'server',
                    toolbar: "#addtool",
                    columns: [{
                        field: 'name',
                        title: '标准名称',
                        formatter:paramsMatter
                    }, {
                        field: 'pzsj',
                        title: '批准时间',
                        formatter:paramsMatter
                    }, {
                        field: 'uploadtime',
                        title: '生效时间',
                        formatter:paramsMatter
                    }, {
                        field: 'pzdw',
                        title: '批准单位',
                        formatter:paramsMatter
                    },{
                        title: '操作',
                        formatter: function (value, row, index) {
                            var aStr = '<a class="czBtn" href="javascript:showPdf2(\''+row.id+'\')">查看</a>';
                            aStr += '<a class="czBtn" href="javascript:downLoad2(\''+row.id+'\')">下载</a>';
                            return aStr;
                        },
                    }],
                    responseHandler: function (res) {  //后台返回的结果
                        if (res.code == "200") {
                            var data = res.data;
                            var NewData = [];
                            for(i=0;i<data.length;i++){
                                var dd = data[i];
                                dd.roleName = roleId2RoleName(dd.roleId);
                                NewData.push(dd);
                            }
                            var data = {
                                total: res.data.total,
                                rows: NewData
                            };
                            return data;
                        }
                    }
                });
            },
            clickflfg:function(){
                this.flfg = true;
                this.hybz = false;
                document.getElementById('fafgBtn').className = 'btn btn-primary btn1';
                document.getElementById('hybzBtn').className = 'btn btn-default btn2';
            },
            clickhybz:function(){
                this.flfg = false;
                this.hybz = true;
                document.getElementById('fafgBtn').className = 'btn btn-default btn2';
                document.getElementById('hybzBtn').className = 'btn btn-primary btn1';
            },
            mySubmit:function () {
                //var  path=vue.$data.path;
                vue.$data.path = encodeURIComponent(vue.$data.path);
                var myMsg = cxLoad("配置中");
                this.$http.post('/updatePath?path='+this.path).then(function (result) {
                    var data = result.body;
                    if (data.code == 200) {
                        layer.close(myMsg);
                        cxAlertOk("配置成功");
                        vue.$data.path = null;
                    }else {
                        layer.close(myMsg);
                        cxAlert(data.mess);
                    }
                });
            }
        },
        mounted:function () {
            var that = this;
            var url = location.search;
            var type = url.substring(url.indexOf("=")+1);
            //1:行业标准
            //0:法律法规
            if(type != "" && type != undefined && type == 0){
                that.clickflfg();
            }else if(type != "" && type != undefined && type == 1){
                that.clickhybz();
            }
            $("#flfgTable").bootstrapTable('destroy');
            $('#flfgTable').bootstrapTable({
                url: '/fglr/api/queryAll',
                contentType: "application/json; charset=UTF-8",
                type: "GET",
                dataType: 'json',
                queryParamsType: "",
                sortName : 'rgsj',
                sortOrder : 'desc',
                singleSelect: true,
                paginationShowPageGo: true,
                pageNumber:1,
                pageSize:5,
                queryParams: function (params) {
                    return {'pageNum':params.pageNumber,'pageSize':params.pageSize,'sort':params.sortOrder};
                },
                striped: true,
                smartDisplay:false,
                cache: false,
                //pagination: true,
                pageList: [5,10],
                sidePagination: 'server',
                toolbar: "#addtool",
                columns: [{
                    field: 'name',
                    title: '标准名称',
                    formatter:paramsMatter
                }, {
                    field: 'pzsj',
                    title: '批准时间',
                    formatter:paramsMatter
                }, {
                    field: 'uploadtime',
                    title: '生效时间',
                    formatter:paramsMatter
                }, {
                    field: 'pzdw',
                    title: '批准单位',
                    formatter:paramsMatter
                },{
                    title: '操作',
                    formatter: function (value, row, index) {
                        var aStr = '<a class="czBtn" href="javascript:showPdf(\''+row.id+'\')">查看</a>';
                        aStr += '<a class="czBtn" href="javascript:downLoad(\''+row.id+'\')">下载</a>';
                        return aStr;
                    },
                }],
                responseHandler: function (res) {  //后台返回的结果
                    if (res.code == "200") {
                        var data = res.data;
                        var NewData = [];
                        for(i=0;i<data.length;i++){
                            var dd = data[i];
                            dd.roleName = roleId2RoleName(dd.roleId);
                            NewData.push(dd);
                        }
                        var data = {
                            total: res.data.total,
                            rows: NewData
                        };
                        return data;
                    }
                }
            });
            $("#hybzTable").bootstrapTable('destroy');
            $('#hybzTable').bootstrapTable({
                url: '/hxbz/api/queryAll',
                contentType: "application/json; charset=UTF-8",
                type: "GET",
                dataType: 'json',
                queryParamsType: "",
                sortName : 'rgsj',
                sortOrder : 'desc',
                singleSelect: true,
                paginationShowPageGo: true,
                pageNumber:1,
                pageSize:5,
                queryParams: function (params) {
                    return {'pageNum':params.pageNumber,'pageSize':params.pageSize,'sort':params.sortOrder};
                },
                striped: true,
                smartDisplay:false,
                cache: false,
                //pagination: true,
                pageList: [5,10],
                sidePagination: 'server',
                toolbar: "#addtool",
                columns: [{
                    field: 'name',
                    title: '标准名称',
                    formatter:paramsMatter
                }, {
                    field: 'pzsj',
                    title: '批准时间',
                    formatter:paramsMatter
                }, {
                    field: 'uploadtime',
                    title: '生效时间',
                    formatter:paramsMatter
                }, {
                    field: 'pzdw',
                    title: '批准单位',
                    formatter:paramsMatter
                },{
                    title: '操作',
                    formatter: function (value, row, index) {
                        var aStr = '<a class="czBtn" href="javascript:showPdf2(\''+row.id+'\')">查看</a>';
                        aStr += '<a class="czBtn" href="javascript:downLoad2(\''+row.id+'\')">下载</a>';
                        return aStr;
                    },
                }],
                responseHandler: function (res) {  //后台返回的结果
                    if (res.code == "200") {
                        var data = res.data;
                        var NewData = [];
                        for(i=0;i<data.length;i++){
                            var dd = data[i];
                            dd.roleName = roleId2RoleName(dd.roleId);
                            NewData.push(dd);
                        }
                        var data = {
                            total: res.data.total,
                            rows: NewData
                        };
                        return data;
                    }
                }
            });
            $('#daxxgmlpz').bootstrapValidator({
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    files: {
                        validators: {
                            stringLength: {
                                max: 150,
                                message: '根目录路径字段长度不能超过150'
                            }
                        }
                    }
                }
            });
        }
    })
</script>
</body>
</html>
